package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceItemscombo;
import com.ruoyi.service.service.IServiceItemscomboService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务项目与套餐对应Controller
 * 
 * @author ZDL
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/service/itemscombo")
public class ServiceItemscomboController extends BaseController
{
    @Autowired
    private IServiceItemscomboService serviceItemscomboService;

    /**
     * 查询服务项目与套餐对应列表
     */
    @PreAuthorize("@ss.hasPermi('service:itemscombo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceItemscombo serviceItemscombo)
    {
        startPage();
        List<ServiceItemscombo> list = serviceItemscomboService.selectServiceItemscomboList(serviceItemscombo);
        return getDataTable(list);
    }

    /**
     * 导出服务项目与套餐对应列表
     */
    @PreAuthorize("@ss.hasPermi('service:itemscombo:export')")
    @Log(title = "服务项目与套餐对应", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceItemscombo serviceItemscombo)
    {
        List<ServiceItemscombo> list = serviceItemscomboService.selectServiceItemscomboList(serviceItemscombo);
        ExcelUtil<ServiceItemscombo> util = new ExcelUtil<ServiceItemscombo>(ServiceItemscombo.class);
        util.exportExcel(response, list, "服务项目与套餐对应数据");
    }

    /**
     * 获取服务项目与套餐对应详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:itemscombo:query')")
    @GetMapping(value = "/{itemscomboId}")
    public AjaxResult getInfo(@PathVariable("itemscomboId") Long itemscomboId)
    {
        return success(serviceItemscomboService.selectServiceItemscomboByItemscomboId(itemscomboId));
    }

    /**
     * 新增服务项目与套餐对应
     */
    @PreAuthorize("@ss.hasPermi('service:itemscombo:add')")
    @Log(title = "服务项目与套餐对应", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceItemscombo serviceItemscombo)
    {
        return toAjax(serviceItemscomboService.insertServiceItemscombo(serviceItemscombo));
    }

    /**
     * 修改服务项目与套餐对应
     */
    @PreAuthorize("@ss.hasPermi('service:itemscombo:edit')")
    @Log(title = "服务项目与套餐对应", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceItemscombo serviceItemscombo)
    {
        return toAjax(serviceItemscomboService.updateServiceItemscombo(serviceItemscombo));
    }

    /**
     * 删除服务项目与套餐对应
     */
    @PreAuthorize("@ss.hasPermi('service:itemscombo:remove')")
    @Log(title = "服务项目与套餐对应", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemscomboIds}")
    public AjaxResult remove(@PathVariable Long[] itemscomboIds)
    {
        return toAjax(serviceItemscomboService.deleteServiceItemscomboByItemscomboIds(itemscomboIds));
    }
}
